localStorage.urlId = Util.GetQueryString('userId')
document.body.addEventListener('touchstart', function () {});
Cardlist.getUserInfo({
	userId: localStorage.urlId
},function(res){
	var keyValArr = []; //存储键盘值
	//身份验证拨号键盘
	$('.keyboarditem').click(function(){
		var keyboardVal = $(this).text();
		var keyValStr = ''; //提交的密码值
		var boxitem = $('.boxitem'); //获取输入框的值
		if(keyboardVal == '0' || keyboardVal == '1' || keyboardVal == '2' || keyboardVal == '3' || keyboardVal == '4' || keyboardVal == '5' || keyboardVal == '6' || keyboardVal == '7' || keyboardVal == '8' || keyboardVal == '9'){
			//将数字键盘值存入数组
			if(keyValArr.length < 6){ //限制数组长度
				keyValArr.push(keyboardVal);
			}
		}else if(keyboardVal == 'Del'){
			keyValArr.pop();
			
		}else if(keyboardVal == '取消'){
			keyValArr = [];
			boxitem.text('');
		}
		for(var i = 0; i<6; i++){
			if(keyValArr[i] != undefined){
				$(boxitem[i]).text('●');
			}else{
				$(boxitem[i]).text('');
			}
		}
		if(keyValArr.length == 6){
			for(var i=0; i<keyValArr.length; i++){
				keyValStr = keyValStr + keyValArr[i];
			}
			Pay.checkPayPwd({
				userId: localStorage.urlId,
				payPwd: $.base64.encode(keyValStr)
			},function(res){
			    localStorage.rpUserId = Util.GetQueryString('userId'); //验证成功后缓存用户Id
				location.hash = 'cardlist';
			})
		}
	});
	
	//确认修改提现密码
	$('.confirm').click(function(){
		var reg = new RegExp("^[0-9]*$");
		var oldPayPwd = $('#oldPayPwd').val();
		var newPayPwd = $('#newPayPwd').val();
		var PayCode = $('#verifyCode').val();
		if(PayCode != ''){
			if(oldPayPwd == newPayPwd && newPayPwd.length == 6 && reg.test(oldPayPwd)){
				Pay.modifyPayPwd({
					userId: localStorage.urlId, //userId
					payPwd: ' ', //原支付密码
					newPayPwd: $.base64.encode(newPayPwd), //新密码
					phone: localStorage.phone, //用户手机号
					verifyCode: PayCode,
					bizType: 2
				},function(res){
					layer.open({content: '添加支付密码成功！' ,skin: 'msg',time: 2});
					setTimeout(function() { 
						localStorage.rpUserId = Util.GetQueryString('userId'); //验证成功后缓存用户Id
						location.hash = 'cardlist';
					},2000);
				})
			}else{
				layer.open({content: '密码不合法' ,skin: 'msg',time: 2});
			}
		}else{
			layer.open({content: '验证码不能为空' ,skin: 'msg',time: 2});
		}

	});
	
	
	//获取修改密码验证码
	$('.getems').click(function(){
		VerifyCode.checkVerifyCode({
			phone: localStorage.phone, //用户手机号
			bizType: 4 //验证码类型
		},function(res){})
	});
});
